package thread.demo.threadLocal;

import java.util.concurrent.TimeUnit;

public class ThreadLocalTest002 {
  static ThreadLocal<String> local = new ThreadLocal<>();
  
  public static void main(String[] args) throws InterruptedException {
    System.out.println(Thread.currentThread().getName());
    new Thread(() -> {
      local.set("name");
      System.out.println("1.");
      System.out.println(local.get());
      System.out.println(Thread.currentThread().getName());
    }).start();
    
    TimeUnit.MILLISECONDS.sleep(100);
    
    new Thread(() -> {
      local.set("age");
      System.out.println("2.");
      System.out.println(local.get());
      System.out.println(Thread.currentThread().getName());
    }).start();
  }
}
